package kr.hkit.powerjava.chapter22.collection;

import java.util.ArrayList;

import kr.hkit.powerjava.chapter22.Array;

public class ArrayListTest {
	public static void main(String[] args) {
		ArrayList<String> arList = new ArrayList<>();
		
		arList.add("MILK");
		
		ArrayList<String> subList = new ArrayList<>();
		subList.add("BREAD"); subList.add("BUTTER");
		
		arList.addAll(subList);
		arList.add(1,"APPLE");
		
		Object[] arr =  arList.toArray();
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]+" ");
		}
		System.out.println();
		
		String[] strArr = new String[arList.size()];
		arList.toArray(strArr);
		for (int i = 0; i < strArr.length; i++) {
			System.out.print(strArr[i]+" ");
		}
		System.out.println();
		arList.clear();
		
		System.out.println("Empty? "+arList.isEmpty());
	/*	boolean result = arList.contains("BREAD");
		arList.remove(1);
		arList.remove("BREAD"); //우리가 정의하면 안됨.. 
								//equals메소드를 오버라이딩 해야함
		
		arList.clear(); //전부 삭제
		
		System.out.println(result); */
		
		for(String str: arList) {
			System.out.println(str);
		}
		
		
		System.out.println("================================");
		for (int i = 0; i < arList.size(); i++) {
			System.out.println(arList.get(i));
		}
		
	}
}
